<template>
  <view class="recommend-list" :style="my_style">
    <view>
      <view class="list">
        <view class="items">
          <view class="item" v-for="(item, i) in category_list" :key="i" @click="tab(i)">
            <text :class="{ 'item-act': itemIndex === i }">{{ item[category_name] }}</text>
            <image v-show="itemIndex === i" src="@/static/goods/qt@2x.png" mode=""></image>
          </view>
        </view>
      </view>
      <view class="h-100"></view>
      <view class="u-p-24">
        <common-list @load="getGoodsRecommendList" :list="list" :status="status">
          <template #list>
            <item-list :list="list" prompt="购买" />
          </template>
          <template #empty>
            <empty text="还没有相关内容～"></empty>
          </template>
        </common-list>
      </view>
    </view>
  </view>
</template>

<script>
  import ItemList from '@/components/goods/ItemList.vue'
  export default {
    props: {
      list: {
        type: Array,
        default: () => [],
      },
      status: {
        type: String,
        default: '',
      },
      category_list: {
        type: Array,
        default: () => [],
      },
      category_name: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        theme_color_rgba: '',
        itemIndex: 0,
      }
    },
    onLoad(options) {},
    components: {
      ItemList,
    },

    methods: {
      onBottom() {
        if (this.status === 'loadmore') {
          this.$emit('loadMore')
        }
      },
      tab(i) {
        this.itemIndex = i
        this.$emit('tab', i)
      },
    },
  }
</script>

<style>
  page {
    background-color: #fff;
  }
</style>

<style lang="scss" scoped>
  .setting-page {
    // empty
  }

  .list {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    display: flex;
    width: 100%;
    height: 100rpx;
    overflow-x: auto;
    background-color: #fff;
    align-items: center;
  }

  .list::-webkit-scrollbar {
    display: none;
  }

  .items {
    display: flex;
    width: auto;
    // align-items: center;
  }

  .item {
    display: flex;
    width: auto;
    padding: 0 20rpx;
    flex-direction: column;
    align-items: center;

    text {
      font-family: PingFangSC-Regular, PingFang SC;
      font-size: 28rpx;
      color: #333;
      white-space: nowrap;
    }

    image {
      width: 28rpx;
      height: 28rpx;
    }
  }

  .item-act {
    font-size: 32rpx !important;
    font-weight: 500 !important;
    color: var(--color) !important;
  }
</style>
